# 用户models的序列化类
import bdb

from applications.exts import ma
from marshmallow import fields, post_load

from applications.models import Carts





class CartsOutSchema(ma.Schema):
    id = fields.Integer()
    gid = fields.Integer()
    openid = fields.Str()
    good_price = fields.Float()
    good_gname = fields.Str()
    good_photo = fields.Str()
    number = fields.Integer()
    update_time = fields.DateTime()


    @post_load  # 使用post_load来装饰json>object的函数
    def make_Carts(self, data, **kwargs):
        return Carts(**data)
